package com.xidian.zhiancloud.controller.luling.TrainingRiskStatusPart;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.TrainingRiskStatus;
import com.xidian.zhiancloud.service.luling.TrainingRiskStatusPart.TrainingRiskStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
/**
 ** 风险培训接口
 * @Author:luling
 * @Date:2021/1/7   15:24
 */
@RestController
@RequestMapping("/TrainingRiskStatus")
public class TrainingRiskStatusController {
    @Autowired
    private TrainingRiskStatusService  trainingRiskStatusService;
    /**
     *添加风险培训信息
     @param   trainingRiskStatus 风险培训对象
     @return ResultDTO 对象
     */
    @PostMapping("/insert")
    public ResultDTO<Boolean> add(@RequestBody TrainingRiskStatus trainingRiskStatus) {
        trainingRiskStatusService.add(trainingRiskStatus);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }
    /**
     * 根据state获取风险培训信息
     *
     * @param state 风险培训state对象
     * @return  返回设施设备对象
     */
    @GetMapping("/getById/{state}")
    public ResultDTO<Object>getById(
            @PathVariable String state) {
        return ResultDTO.successOf(trainingRiskStatusService.getById(state), GeneralResponseEnums.SUCCESS);
    }
    /**
     * 列表查询
     *
     * @param  state 状态
     * @param startTimeTrain 培训开始时间
     * @param  lecturer  授课人
     * @param  locale  培训地点
     * @param riskProject  风险项目
     * @param   key    关键字
     * @param current   分页偏移量
     * @param size    每一页的数量
     * @return 返回风险培训列表
     **/
    @GetMapping("/getList")
    public ResultDTO<Object>getList(@RequestParam(value = "state", required = false) String state,
                             @RequestParam(value = "startTimeTrain", required = false) Date startTimeTrain,
                             @RequestParam(value = "lecturer", required = false) String lecturer,
                             @RequestParam(value = "locale", required = false) String locale,
                             @RequestParam(value = "riskProject", required = false) String riskProject,
                             @RequestParam(value = "key", required = false) String key,
                             @RequestParam(value = "current", required = true) int current,
                             @RequestParam(value = "size", required = true) int size) {
        return ResultDTO.successOf(trainingRiskStatusService.getList(state, startTimeTrain, lecturer,locale,riskProject,key,current, size), GeneralResponseEnums.SUCCESS);
    }
    //导出

}
